/*
 * CategoryClassificationDoubleCheck is a software package that uses 
 * data mining to verify that descriptions of items are classified 
 * into the correct categories.
 * 
 * Copyright (C) 2011  CommuniPatient, LLC
 * 
 * File: ItemSuggestion.java
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *  
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package com.unitvectory.categoryclassification;

/**
 * Represents a category change suggestion for an item.
 * 
 * @author Jared Hatfield
 * 
 */
public class ItemSuggestion {

	/**
	 * The item.
	 */
	private Item item;

	/**
	 * The category.
	 */
	private Category category;

	/**
	 * Flag indicating the item should be added or removed from category.
	 */
	private boolean add;

	/**
	 * The confidence of the prediction.
	 */
	private double confidence;

	/**
	 * Initializes a new instance of the ItemSuggestion class.
	 * 
	 * @param item
	 *            The item.
	 * @param category
	 *            The category.
	 * @param add
	 *            The add flag.
	 * @param confidence
	 *            The confidence.
	 */
	public ItemSuggestion(Item item, Category category, boolean add,
			double confidence) {
		this.item = item;
		this.category = category;
		this.add = add;
		this.confidence = confidence;
	}

	/**
	 * Gets the item.
	 * 
	 * @return The item.
	 */
	public Item getItem() {
		return item;
	}

	/**
	 * Gets the category.
	 * 
	 * @return The category.
	 */
	public Category getCategory() {
		return category;
	}

	/**
	 * Gets the add flag.
	 * 
	 * @return The add flag.
	 */
	public boolean isAdd() {
		return add;
	}

	/**
	 * Gets the confidence.
	 * 
	 * @return The confidence.
	 */
	public double getConfidence() {
		return confidence;
	}

	/**
	 * Returns the string representation for the ItemSuggestion.
	 */
	@Override
	public String toString() {
		double number = Math.round(this.confidence * 10000) / 100.0;
		if (this.add) {
			return "Add " + this.item.getName() + " (" + this.item.getId()
					+ ") to " + this.category.getName() + " ("
					+ this.category.getId() + ") with confidence " + number;
		} else {
			return "Remove " + this.item.getName() + " (" + this.item.getId()
					+ ") from " + this.category.getName() + " ("
					+ this.category.getId() + ") with confidence " + number;
		}
	}
}
